<?
    $launcher_name = $request->get("launcher", "none");

    if($launcher_name eq "none") {
        @launchers = sort $EQW->ListLaunchers();
        my $launcher_count = @launchers;
        print "{";
        print "\"launcher_count\" : $launcher_count,";
        print "\"launchers\" : ";
        print "[";

        my $i = 0;
        for my $lk (@launchers) {
            my $l = $EQW->GetLauncher($lk);
            print "{";
            print "\"name\" : \"". $l->GetName() ."\",";
            print "\"static_count\" : ". $l->GetStaticCount() .",";
            print "\"dynamic_count\" : ". $l->GetDynamicCount() .",";
            $conn = 0;
            if($l->IsConnected()) {
                $conn = 1;
            }
            print "\"connected\" : ". $conn;
            print "}";

            if($i != $launcher_count - 1) {
                print ",";
            }
            $i++;
        }

        print "]";
        print "}";
    } else {
        my $l = $EQW->GetLauncher($lname);
        print "{";
        print "\"name\" : \"". $l->GetName() ."\",";
        print "\"static_count\" : ". $l->GetStaticCount() .",";
        print "\"dynamic_count\" : ". $l->GetDynamicCount() .",";
        $conn = 0;
        if($l->IsConnected()) {
            $conn = 1;
        }
        print "\"connected\" : ". $conn . ",";
        my @zones = $l->ListZones();
        my $zone_count = @zones;
        print "\"zone_count\" : ". $zone_count . ",";
        print "\"zones\" : ";
        print "[";
        my $i = 0;
        for my $zone (@zones) {
            my $z = $config->GetZoneDetails($zone);
            print "{";
                print "\"name\" : \"$z->{name}\",";
                print "\"up\" : $z->{up},";
                print "\"starts\" : $z->{starts},";
                print "\"port\" : $z->{port}";
            print "}";

            if($i != $zone_count - 1) {
                print ", ";
            }
            $i++;
        }

        print "]";
        print "}";
    }
?>